<template>
  <div>
    <div>
      <table border="1" width="500" cellspacing="0">
        <tr>
          <th>编号</th>
          <th>品牌名称</th>
          <th>创立时间</th>
          <th>操作</th>
        </tr>
        <tr v-for="(item, index) in arr" :key="item.id">
          <td>{{ index + 1 }}</td>
          <td>{{ item.name }}</td>
          <td>{{ item.time }}</td>
          <td><button @click="fn(item.id)">删除</button></td>
        </tr>
        <tr>
          <td v-show="arr.length === 0 ? true : false">没有任何数据了哦</td>
        </tr>
      </table>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [
        { id: 1, name: "奔驰", time: "2020-08-01" },
        { id: 2, name: "宝马", time: "2020-08-02" },
        { id: 3, name: "奥迪", time: "2020-08-03" },
      ],
    };
  },
  methods: {
    fn(id) {
      this.arr = this.arr.filter((item) => item.id !== id);
    },
  },
};
</script>

<style>
</style>